<title><?=$v['title']?></title>
<script src="js/ui/PopWindow.js" type="text/javascript"></script>
<script src="js/Calendar.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="css/default.css"/>
<link rel="stylesheet" type="text/css" href="css/page.css"/>
<link rel="stylesheet" type="text/css" href="css/sell_product.css"/>
<style>
    .btn{padding: 4px 15px;background: url("images/mc_title.png") no-repeat right top;color: #fff;border: none;cursor: pointer;}
    #oneCount{height:26px;}
</style>
<div class="content">
    <h3 class="mc_title">
        <span class="mctit_1"><span class="mctit_2"><?=$v['title']?></span></span>
    </h3>
    <div class="mcsear_box">
        <form action="<?=$_SERVER['PHP_SELF']?>" class="report">
            <input type="hidden" name="act" id="act" />
            <input type="hidden" name="atype" value="<?=$atype?>" />
            <input type="hidden" name="currentPage" value="1"/>
            <input type="hidden" name="status" id="status" value="<?=$_REQUEST['status']?>"/>
            <ul class="search">
                <li>
                    <span>
                        <label>查询条件：</label>
                        <select name="tjs" class="sType">
                            <option value="">--请选择--</option>
                            <option <?=$_REQUEST['tjs']=="0"?"selected":""?> value="0">订单号</option>
                            <option <?=$_REQUEST['tjs']=="1"?"selected":""?> value="1">产品名称</option>
                            <option <?=$_REQUEST['tjs']=="2"?"selected":""?> value="2">取票人姓名</option>
                            <option <?=$_REQUEST['tjs']=="3"?"selected":""?> value="3">取票人手机</option>
                            <?php if($v['from']!="buy"):?>
                            <option <?=$_REQUEST['tjs']=="4"?"selected":""?> value="4">分销商名称</option>
                            <?php endif;?>
                            <?php if($v['from']=="buy"||$_SESSION['dtype']==9):?>
                            <option <?=$_REQUEST['tjs']=="5"?"selected":""?> value="5">供应商名称</option>
                            <?php endif;?>
                            <option <?=$_REQUEST['tjs']=="6"?"selected":""?> value="6">远端订单号</option>
                        </select>
                        <?php if( !$hideList && ($_REQUEST['tjs']==5 || $_REQUEST['tjs']==4)):?>
                        <select style="width:180px;height:23px;border: 1px solid #2A98DA;box-shadow: 1px 1px 1px #B0DFFD;" class="distors" name="txt">
                            <? foreach($DistorsNames as $k):?>
                            <?
                                $selected='';
                                if ($_REQUEST['txt']==substr($k,2))
                                    $selected='selected="selected"';//
                            ?>
                            <option value="<?=substr($k,2)?>" <?=$selected?>><?=$k?></option>
                            
                            <?endforeach;?>
                        </select>
                        <?endif;?>
                        <?
                        $style='';
                        $names='name="txt"';
                        if(!$hideList && ($_REQUEST['tjs']==5 || $_REQUEST['tjs']==4)){
                            $style='style="display:none;"';
                            $names='';
                        }
                        ?>
                        <input type="text" <?=$names?>  class="inputText svalue" value="<?=$_REQUEST['txt']?>" <?=$style?>/>
                    </span>
                    <span>
                        <label>支付方式：</label>
                        <input type="checkbox" name="payinfo[]" <?=(in_array(0,$_REQUEST['payinfo']))?"checked":""?> value="0" />
                        <label for="mck1">账户余额</label>
                        <input type="checkbox" name="payinfo[]" <?=(in_array(1,$_REQUEST['payinfo']))?"checked":""?> value="1"/>
                        <label for="mck2">支付宝</label>
                        <input type="checkbox" name="payinfo[]" <?=(in_array(2,$_REQUEST['payinfo']))?"checked":""?> value="2"/>
                        <label for="mck3">授信支付</label>
                    </span>
                    <span>
                        <input type="submit" class="sbtn" value=""/>

                    </span>
                </li>
                <li>
                    <span>
                        <label>订单时间：</label>
                        <select class="" name="xtimes">
                            <option <?=$_REQUEST['xtimes']=="1"?"selected":""?> value="1">--下单时间-</option>
                            <option <?=$_REQUEST['xtimes']=="2"?"selected":""?> value="2">--预计游玩-</option>
                            <option <?=$_REQUEST['xtimes']=="3"?"selected":""?> value="3">--完成时间-</option>    
                        </select>
                        <input type="text" name="begintime" readOnly onmouseup="SelectDate(this,'yyyy-MM-dd',0,0)"  class="inputText time" value="<?=$_REQUEST['begintime']?>"/>
                        <label>至</label>
                        <input type="text" name="endtime" readOnly onmouseup="SelectDate(this,'yyyy-MM-dd',0,0)" class="inputText time" value="<?=$_REQUEST['endtime']?>"/>
                    </span>
                    <span>
                        <label>搜索排序：</label>
                        <select name="orderby">
                            <option value="">--请选择--</option>
                            <option <?=$_REQUEST['orderby']=="1"?"selected":""?> value="1" >-下单时间-</option>
                            <option <?=$_REQUEST['orderby']=="2"?"selected":""?> value="2" >-游玩时间-</option>
                            <option <?=$_REQUEST['orderby']=="3"?"selected":""?> value="3" >-验证时间-</option>
                            <option <?=$_REQUEST['orderby']=="5"?"selected":""?> value="5" >-产品标题-</option>
                        </select>
                        <select name="sort">
                            <option <?=$_REQUEST['sort']=="1"?"selected":""?> value="1" >-降序-</option>
                            <option <?=$_REQUEST['sort']=="0"?"selected":""?> value="0" >-升序-</option>
                        </select>
                    </span>
                    <input type="button" id="excel" class="btn" value="导 出"/>
                </li>
            </ul>
        </form>
        <ul class="mcul">
            <li class="<?=!isset($_REQUEST['status'])||$_REQUEST['status']===""?"acrt":""?>"><a href="#" status="" >所有订单</a></li>
            <li class="<?=$_REQUEST['status']=="1"?"acrt":""?>"><a href="#" status="1" >已使用</a></li>
            <li class="<?=$_REQUEST['status']=="0"?"acrt":""?>"><a href="#" status="0" >未使用</a></li>
            <li class="<?=$_REQUEST['status']=="2"?"acrt":""?>"><a href="#" status="2" >已过期</a></li>
            <li class="<?=$_REQUEST['status']=="3"?"acrt":""?>"><a href="#" status="3" >已取消</a></li>
        </ul>
        
    </div>
   <div class="section popupwz">
        <table class="mclist_tab">
            <tfoot class="counts">
                    <td colspan="11" class="surtd">
                    <span style="float:right; margin-right:25px; line-height:30px;">
                    <h4>
                        统计结果：
                        <span>订单数：<em class="green"><?=$orderCount?></em>单</span>
                        <span>数 量：<em class="pink"><?=$ticketCount?></em></span>
                        <span>总金额：<em class="red"><?=$allMoney?></em>元</span>
                    </h4>
                    </span>
                    </td>
            </tfoot>
            <thead>
                <tr class="thead1"></tr>
                <tr class="thead2">
                    <td colspan="9">
                        <div id="topPage">
                        <?page($count,$currentPage,$pageSize,$order,$by);?>
                        </div>
                    </td>
                </tr>
                </thead>
        </table>
        <table class="orders" id="orders" >
            <thead>
                <th width="52" class="tl">订单号</th>
                <th width="160">产品信息</th>
                <th width="43">单价</th>
                <th colspan="3">取票人信息</th>
                <th width="135"><?=$dTypeName?></th>
                <th width="63">支付方式</th>
                <th width="90">订单状态</th>
                <th width="150">操作</th>
            </thead>
            <?php if(count($r)):?>
            <tbody>
            <?php foreach($r as $row):?>
            <tr>
              <td rowspan="2" class="borsoli"><a target="_blank" href="orderView.html?from=<?=$v['from']?>&ordernum=<?=$row['mainOrder']->UUordernum?>" class="ordernb"><?=(string)$row['mainOrder']->UUordernum?></a></td>
              <td colspan="8" class="txtleft">
                <?php if((string)$row['mainOrder']->UUremotenum):?>
                   <span>远端订单号：<?=(string)$row['mainOrder']->UUremotenum?></span></br>
                <?php endif;?>
                  <span>下单时间：<?=(string)$row['mainOrder']->UUordertime?></span>
                  <span>有效期:<?=(string)$row['mainOrder']->UUbegintime?> 至 <?=(string)$row['mainOrder']->UUendtime?></span>
                  <span>验证时间：<?=(string)$row['mainOrder']->UUdtime!="0000-00-00 00:00:00"?(string)$row['mainOrder']->UUdtime:"未验证"?></span>
              </td>
              <td rowspan="2" class="rigsoli"> 
                  <span class="vidhid show">
                   <?if(!isMainOrder($row['mainOrder']->UUconcat_id)):?>
                        <?if(!isMainOrder($row['mainOrder']->UUconcat_id)):?>合计：<span style=" color:#f60; font-size:14px; font-weight:bold; line-height:21px;">
                        <span class="money"><i class="money">￥</i><?=(string)$row['totalPrice']/100?></span>
                        <?endif;?></span><br />
                        <?php if(OrderRecord::orderOperAuth($row,$memberID,$_SESSION['account'],"orderView")):?>
                        <a target="_blank" href="orderView.html?from=<?=$v['from']?>&ordernum=<?=$row['mainOrder']->UUordernum?>">查看</a></br>
                        <?php endif;?> </span>
                        <?php if(OrderRecord::orderOperAuth($row,$memberID,$_SESSION['account'],"orderAlipay")):?>
                        <a target="_blank" href="alipayOrder.html?ordernum=<?=(string)$row['mainOrder']->UUordernum?>">支付</a></br>
                        <?php endif;?>
                  <span class="vidhid ">
                     <?if(OrderRecord::orderOperAuth($row,$memberID,$_SESSION['account'],"orderCancel")):?>
                        <a act="cancel" class="orderHandle" href="call/handle.php?from=order_cancel&&ordernum=<?=(string)$row['mainOrder']->UUordernum?>">取消</a>
                        <?php endif;?></span>
                  <span class="vidhid ">
                     <?if(OrderRecord::orderOperAuth($row,$memberID,$_SESSION['account'],"orderAlipay")):?>
                        <a target="_blank" href="alipayOrder.html?ordernum=<?=(string)$row['mainOrder']->UUordernum?>">支付</a></br>
                     <?php endif;?>
                  </span>
                  <?if(OrderRecord::orderOperAuth($row,$memberID,$_SESSION['account'],"orderCancel")):?>
                  <span class="vidhid show">
                      <a act="cancel" class="orderHandle" href="call/handle.php?from=order_cancel&&ordernum=<?=(string)$row['mainOrder']->UUordernum?>">取消</a>
                  </span>
                  <?php endif;?>
                  <?php if(OrderRecord::orderOperAuth($row,$memberID,$_SESSION['account'],"orderAlter")):?>
                  <span class="vidhid show">
                      <a class="alter" href="call/handle.php?from=orderAlterHtml&&ordernum=<?=(string)$row['mainOrder']->UUordernum?>">修改</a>
                  </span>
                  <?php endif;?>
                  <?php if($row['mainOrder']->UUstatus==0 && $row['mainOrder']->UUpaystatus==1):?>
                  <span class="vidhid show">
                        <a act="cancel" class="resend" href="call/handle.php?from=order_resend&&ordernum=<?=(string)$row['mainOrder']->UUordernum?>">重发</a>
                   </span>
                  <?endif;?>
                  <span class="vidhid show">
                        <?php if(isMainOrder($row['mainOrder']->UUconcat_id)):?>
                            <?php if(OrderRecord::orderOperAuth($row,$memberID,$_SESSION['account'],"orderAlipay")):?>
                            <a target="_blank" href="alipayOrder.html?ordernum=<?=(string)$row['mainOrder']->UUordernum?>">支付</a></br>
                            <?php endif;?>
                            <span>复票订单</br><a href="orderView.html?from=<?=$v['from']?>&ordernum=<?=echoMainOrder($row['mainOrder'])?>" target="_blank">查看详细</a></span>
                        <?endif;?>
                        <?if($_SESSION['dtype']==2 && in_array($_SESSION['account'],$arr_salerid)):?>
                            <span><?=$row['mainOrder']->UUcode?></span>
                        <?endif;?>
                    </span>
              </td>
            </tr>
            <tr>
                <td class="txtleft"><!--<span style="display:none;color:green; margin-right:8px;" title=""></span>--><?=(string)$row['mainOrder']->UUltitle?></br>【<?=(string)$row['mainOrder']->UUttitle?>】<span style="color:#FC6602; font-size:14px;text-align:center"><?if(!isMainOrder($row['mainOrder']->UUconcat_id)):?>
                        *<?=(string)$row['mainOrder']->UUtnum?>
                        张</span></td><?endif;?>
                <td><?if(!isMainOrder($row['mainOrder']->UUconcat_id)):?>
                        <i class="money">￥</i><?=(string)$row['mainOrder']->UUtprice/100?>
                        <?endif;?></td>
                <td colspan="3"><span><?=(string)$row['mainOrder']->UUordername?></span></br><span><?=(string)$row['mainOrder']->UUordertel;//.'|'.$row['mainOrder']->UUaids;?></span></td>
                <td rowspan="1">
                    <?
                        if($v['from']=='buy'){// 已买到
                            echo $anames[(int)$row['mainOrder']->UUsellid]?$anames[(int)$row['mainOrder']->UUsellid]:(string)$row['mainOrder']->UUdname;
                        }else{// 已卖出
                            echo $fnames[(int)$row['mainOrder']->UUbuyid]?$fnames[(int)$row['mainOrder']->UUbuyid]:(string)$row['mainOrder']->UUdname;
                        }
                    ?>
                </td>
                <td rowspan="<?=$row['totalOrder']?>"><?=OrderRecord::$paymodeT[(string)$row['mainOrder']->UUpmode]?>
                        <?php if($row['mainOrder']->UUordermode!=0):?>
                        </br><em class="fuchsia">(游客预订)</em>
                        <?php endif;?>
                        <?php if(((string)$row['mainOrder']->UUordername=='游客' || (string)$row['mainOrder']->UUordername=='淘宝码商') && strlen((string)$row['mainOrder']->UUremotenum)==15):?>
                        </br><em class="fuchsia">(淘宝/天猫)</em>
                        <?php endif;?>
                    </td>
                <td>
                    <span rowspan="<?=$row['totalOrder']?>" data="<?=(string)$row['mainOrder']->UUstatus?>"><?=OrderRecord::$UUstatusT[(int)$row['mainOrder']->UUstatus]?>
                        <?php if($row['mainOrder']->UUstatus==0):?>
                        </br><?=OrderRecord::$paystatusT[(string)$row['mainOrder']->UUpaystatus]?>
                        <?php endif;?>
                    </span>
                </td>
               </tr>
            <?php endforeach;?>
            <?php endif;?>
            </tbody>
            <tfoot class="counts">
                <tr>
                    <td colspan="11" class="surtd">
                    <span style="float:right; margin-right:25px; line-height:30px;">
                    <h4>
                        统计结果：
                        <span>订单数：<em class="green"><?=$orderCount?></em>单</span>
                        <span>数 量：<em class="pink"><?=$ticketCount?></em></span>
                        <span>总金额：<em class="red"><?=$allMoney?></em>元</span>
                    </h4>
                    </span>
                    </td>
                </tr>
            </tfoot>
    </table>
</div>
            </thead>
            <?
                if(count($r)){
                foreach($r as $key=>$row){
                    $arr_salerid=array(501610,501612);
            ?>
            </tbody>
            <?}?>
        </table>    
        <?page($count,$currentPage,$pageSize,$order,$by);?>
   </div>
</div>
<script>
    var popWindow=new PopWindow();
    $(".alter").click(function(){
        $.ajax({
            "url":$(this).attr("href"),
            "success":function(data){
                popWindow.open(data);
                $("form.changetnum input.cancel").click(function(){
                    popWindow.close();
                });
                $("form.changetnum").submit(function(){
                    popWindow.close();
                    var str=$(this).serialize();
                    $.ajax({
                        "url":"call/handle.php?from=order_alter&"+str,
                        "dataType":"json",
                        "success":function(data){
                            if(data.outcome==1){
                                alert(data.msg);
                                window.location=window.location.href;
                            }else{
                                alert(data.msg);
                            }
                        }
                    });
                    return false;
                });
                
            }
        })
        return false;
    });
    $(".orderHandle").click(function(){
        if($(this).attr("act")=="cancel"){
            if(!confirm("确定要取消该订单？")) return false;
        }
        $.ajax({
            "url":$(this).attr("href"),
            "dataType":"json",
            "success":function(data){
                if(data.outcome==1){
                    alert("取消成功");
                    window.location=window.location.href;
                    /*$(this).parent().prev().prev().html('<em class="red">已取消</em>');
                    var textT=$(this).find("a").first().text();
                    $(this).parent().html(textT);*/
                }else{
                    alert("取消失败"+data.msg);
                }
            }
        })
        return false;
    });
    $(".resend").click(function(){
        if($(this).attr("act")=="cancel"){
            if(!confirm("确定要重发短信？")) return false;
        }
        $.ajax({
            "url":$(this).attr("href"),
            "dataType":"json",
            "success":function(data){
                if(data.outcome==1){
                    alert("重发成功");
                }else{
                    alert("重发失败:"+data.msg);
                }
            }
        })
        return false;
    });
    $(".mcul li a").click(function(){
        $("#status").val($(this).attr("status"));
        $(".sbtn").click();
        return false;
    })
    
    $("#excel").click(function(){
        
        // if(!$("#oneCount").hasClass("ready")){
            
            // $.ajax({
                // type:'get',
                // url:'loadText_dt.php',
                // data:"<?=$_SERVER['QUERY_STRING']?>",
                // success:function(data){
                    // size = 1000;// 每次导出多少条
                    // l = Math.ceil(data/size);//共需导出多少次
                    // var tr='';
                    // for(var i=0;i<l;i++){
                        // tr+='<option value="'+(i+1)+'">'+((i)*size+1)+' - '+((i+1)*size)+'</option>';
                    // }
                    // $("#oneCount").html('').append(tr).addClass("ready");
                    // alert(data);
                // }
            // });
            // alert('系统正在计算订单总数，请稍后...');
            // return false;
        // }
        $("#act").val("Export");
        $("form.report").submit();
        $("#act").val("");
    });
    
    <?if(!$hideList):?>
    // 按供应商查询获取供应商列表
    $(".sType").change(function(){
        if($(this).val()!=5 && $(this).val()!=4){
            $(".svalue").show().attr("name","txt");
            if($(".distors").length>0){
                $(".distors").hide().removeAttr("name");
            }
            return 0;
        }
            
        
        //如果有列表，不重复获取
        if($(".distors").length>0){
            $(".svalue").hide().removeAttr("name");
            $(".distors").show().attr("name","txt");
            return 0;
        }
        _parent = $(this).parent();
        $.ajax({
            uri:window.location.href,
            beforeSend:function (XMLHttpRequest) {
                XMLHttpRequest.setRequestHeader("request_type","getDistors");
            },
            success: function(data){
                data = JSON.parse(data);
                if(data.s=='success'){
                    var selectTxt ='<select style="width:180px;height:23px;border: 1px solid #2A98DA;box-shadow: 1px 1px 1px #B0DFFD;" class="distors" name="txt">';
                    selectTxt+='<option value="">--选择--</option>';
                    var aList = [];
                    for(var i in data.d){
                        aList.push(data.d[i]);
                    }
                    aList.sort();
                    for(var j in aList){
                        selectTxt+='<option value="'+aList[j].substr(2)+'">'+aList[j]+'</option>';
                    }
                    selectTxt+='</select>';
                    $(".svalue").hide().removeAttr("name");
                    _parent.append(selectTxt);
                }
            }
        });
        
    });
    <?endif;?>
</script>